package com.conferences.model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

@Entity
@Table(name = "conferences")
public class Conference implements Serializable {

	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private Long id;

	@Column(name = "subject")
	private String subject;

	@Column(name = "content")
	private String content;

	@ManyToOne(fetch=FetchType.EAGER)
	@JoinColumn(name = "author_id")
	private User author;

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "created_date")
	private Date date;

	@ManyToOne
	@JoinColumn(name = "status_id")
	private ConferenceStatus status;

	@Column(name = "person_limit")
	private Integer personLimit;
	
	@ManyToMany(fetch=FetchType.EAGER)
	@JoinTable(name = "user_conference", joinColumns = @JoinColumn(name = "conference_id"), inverseJoinColumns = @JoinColumn(name = "user_id"))
	private List<User> users = new ArrayList<User>();

	public List<User> getUsers() {
		return users;
	}

	public void setUsers(List<User> users) {
		this.users = users;
	}
	
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getSubject() {
		return subject;
	}

	public void setSubject(String subject) {
		this.subject = subject;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public User getAuthor() {
		return author;
	}

	public void setAuthor(User author) {
		this.author = author;
	}

	public Date getDate() {
		return date;
	}

	public void setDate(Date date) {
		this.date = date;
	}

	public ConferenceStatus getStatus() {
		return status;
	}

	public void setStatus(ConferenceStatus status) {
		this.status = status;
	}

	public Integer getPersonLimit() {
		return personLimit;
	}

	public void setPersonLimit(Integer personLimit) {
		this.personLimit = personLimit;
	}
}
